<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05_流程控制</title>
</head>
<body>
<script>
    //1.顺序结构
    console.log(1);
    console.log(2);
    console.log(3);

    //2.分支结构
    let username = '花花';
    // 若用户名为空字符串 转换布尔是false !false为true 走分支1
    if(!username){
        alert('用户名不能为空!');
    }else{
        alert('欢迎'+username+'回来！');
    }

    //3.选择分支
    let gender = 3;
    switch(gender){
        case 1:
            console.log('先生');
            break;
        case 0:
            console.log('女士');
            break;
        default:
            console.log('保密');
        }
        //4.循环结构
    let name = ['hua','gu', 'sen','yang' ]
    for (let i = 0; i < name.length; i++) {
        console.log(name[i]);
    }

    for(let n of name){
        console.log(n)
    }
</script>
</body>
</html>